<?php
function goParam($params,$url = '') {
	$params = array_merge($_GET,$params);
	return $url . '?' . http_build_query($params);
}

function color($dec) {
	$hex = dechex($dec);
	return preg_replace('/^.{2}/','#',$hex);
}

function rgbaToRgb($rgba) {
	return preg_replace('/\#.{2}(.+)/','#${1}',$rgba);
}

function detail($detail) {
	$detail = nl2br($detail);
	
	$faces = ["[呵呵]" => "./static/face/face01.png","[哈哈]" => "./static/face/face02.png","[吐舌]" => "./static/face/face03.png","[啊]" => "./static/face/face04.png","[酷]" => "./static/face/face05.png","[怒]" => "./static/face/face06.png","[开心]" => "./static/face/face07.png","[汗]" => "./static/face/face08.png","[泪]" => "./static/face/face09.png","[黑线]" => "./static/face/face10.png","[鄙视]" => "./static/face/face11.png","[不高兴]" => "./static/face/face12.png","[真棒]" => "./static/face/face13.png","[钱]" => "./static/face/face14.png","[疑问]" => "./static/face/face15.png","[阴险]" => "./static/face/face16.png","[吐]" => "./static/face/face17.png","[咦]" => "./static/face/face18.png","[委屈]" => "./static/face/face19.png","[花心]" => "./static/face/face20.png","[呼~]" => "./static/face/face21.png","[笑眼]" => "./static/face/face22.png","[冷]" => "./static/face/face23.png","[太开心]" => "./static/face/face24.png","[滑稽]" => "./static/face/face25.png","[勉强]" => "./static/face/face26.png","[狂汗]" => "./static/face/face27.png","[乖]" => "./static/face/face28.png","[睡觉]" => "./static/face/face29.png","[惊哭]" => "./static/face/face30.png","[升起]" => "./static/face/face31.png","[惊讶]" => "./static/face/face32.png","[喷]" => "./static/face/face33.png","[爱心]" => "./static/face/face34.png","[心碎]" => "./static/face/face35.png","[玫瑰]" => "./static/face/face36.png","[礼物]" => "./static/face/face37.png","[彩虹]" => "./static/face/face38.png","[星星月亮]" => "./static/face/face39.png","[太阳]" => "./static/face/face40.png","[铅笔]" => "./static/face/face41.png","[灯泡]" => "./static/face/face42.png","[茶杯]" => "./static/face/face43.png","[蛋糕]" => "./static/face/face44.png","[音乐]" => "./static/face/face45.png","[haha]" => "./static/face/face46.png","[胜利]" => "./static/face/face47.png","[大拇指]" => "./static/face/face48.png","[弱]" => "./static/face/face49.png","[OK]" => "./static/face/face50.png"];
	foreach($faces as $name => $img) {
		$detail = str_replace($name,"<img src='{$img}' width='20'>",$detail);
	}
	
	$detail = preg_replace('/<image>(.+?),(\d+),(\d+)<\/image>/','<div class="text-center mt-3 mb-3"><img src="${1}" style="width:${2};max-width:100%"></div>',$detail);
	
	return $detail;
}

function getFaces() {
	return ["[呵呵]" => "./static/face/face01.png","[哈哈]" => "./static/face/face02.png","[吐舌]" => "./static/face/face03.png","[啊]" => "./static/face/face04.png","[酷]" => "./static/face/face05.png","[怒]" => "./static/face/face06.png","[开心]" => "./static/face/face07.png","[汗]" => "./static/face/face08.png","[泪]" => "./static/face/face09.png","[黑线]" => "./static/face/face10.png","[鄙视]" => "./static/face/face11.png","[不高兴]" => "./static/face/face12.png","[真棒]" => "./static/face/face13.png","[钱]" => "./static/face/face14.png","[疑问]" => "./static/face/face15.png","[阴险]" => "./static/face/face16.png","[吐]" => "./static/face/face17.png","[咦]" => "./static/face/face18.png","[委屈]" => "./static/face/face19.png","[花心]" => "./static/face/face20.png","[呼~]" => "./static/face/face21.png","[笑眼]" => "./static/face/face22.png","[冷]" => "./static/face/face23.png","[太开心]" => "./static/face/face24.png","[滑稽]" => "./static/face/face25.png","[勉强]" => "./static/face/face26.png","[狂汗]" => "./static/face/face27.png","[乖]" => "./static/face/face28.png","[睡觉]" => "./static/face/face29.png","[惊哭]" => "./static/face/face30.png","[升起]" => "./static/face/face31.png","[惊讶]" => "./static/face/face32.png","[喷]" => "./static/face/face33.png","[爱心]" => "./static/face/face34.png","[心碎]" => "./static/face/face35.png","[玫瑰]" => "./static/face/face36.png","[礼物]" => "./static/face/face37.png","[彩虹]" => "./static/face/face38.png","[星星月亮]" => "./static/face/face39.png","[太阳]" => "./static/face/face40.png","[铅笔]" => "./static/face/face41.png","[灯泡]" => "./static/face/face42.png","[茶杯]" => "./static/face/face43.png","[蛋糕]" => "./static/face/face44.png","[音乐]" => "./static/face/face45.png","[haha]" => "./static/face/face46.png","[胜利]" => "./static/face/face47.png","[大拇指]" => "./static/face/face48.png","[弱]" => "./static/face/face49.png","[OK]" => "./static/face/face50.png"];
}